package com.scy.java.thread;

public class SaleTicked {
    public static void main(String[] args) {
        Window w1 = new Window("窗口1");
        Window w2 = new Window("窗口2");
        Window w3 = new Window("窗口3");
        //启动线程开始售票
        w1.start();
        w2.start();
        w3.start();
    }
}
class Window extends Thread{
    private static int ticket = 100 ;
    public Window(String name) {
        super(name);
    }
    @Override
    public void run() {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        while (ticket > 0){
                System.out.println(getName()+"卖出了1张票，票号："+ticket);
            ticket--;
        }
    }
}
